﻿using System.Xml.Serialization;

namespace Koala.Pro.Core;

public delegate void PageInfoChanged(PagerInfo info);

[Serializable]
public class PagerInfo
{
    private int currenetPageIndex;

    private int pageSize;

    private int recordCount;

    [XmlElement(ElementName = "CurrenetPageIndex")]
    public int CurrentPageIndex
    {
        get
        {
            return currenetPageIndex;
        }
        set
        {
            currenetPageIndex = value;
            OnPageInfoChanged?.Invoke(this);
        }
    }

    [XmlElement(ElementName = "PageSize")]
    public int PageSize
    {
        get
        {
            return pageSize;
        }
        set
        {
            pageSize = value;
            OnPageInfoChanged?.Invoke(this);
        }
    }

    [XmlElement(ElementName = "RecordCount")]
    public int RecordCount
    {
        get
        {
            return recordCount;
        }
        set
        {
            recordCount = value;
            OnPageInfoChanged?.Invoke(this);
        }
    }

    public event PageInfoChanged OnPageInfoChanged;

    public PagerInfo()
    {
        pageSize = 50;
        currenetPageIndex = 1;
    }
}